<?php

require_once "includes/database/DatabaseController.php";

if ($_SERVER['REQUEST_METHOD'] !== 'POST' || !isset($_POST['sectionId']) || !isset($_POST['articleId']) || !isset($_POST['action']))
{
    exit();
}

$action = $_POST['action'];
$sectionId = $_POST['sectionId'];
$articleId = $_POST['articleId'];

$dbc = new DataBaseController;
$article = $dbc->getArticle($articleId);
if ($action == 'moveUp')
    $dbc->moveUp($article);
else if ($action == 'moveDown')
    $dbc->moveDown($article);

print($action);

header('Location: section.php?section=' . $sectionId . '&article=' . $articleId);
?>
